package com.lemner.ke.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lemner.ke.R;
import com.lemner.ke.base.BaseActivity;
import com.lemner.ke.base.BaseListener;
import com.lemner.ke.base.BaseObjectBean;
import com.lemner.ke.bean.UserBean;
import com.lemner.ke.model.persional.GetUserByIdsModel;
import com.lemner.ke.util.SpUtils;
/**

* 作者：张恺

* 时间：2018/10/16

* 类描述：账号与安全页面

*/

public class AccountSecurityActivity extends BaseActivity {
    private RelativeLayout rl_phone,rl_password;
    private TextView tv_mobile;
    @Override
    public int getLayoutFile() {
        return R.layout.activity_account_security;
    }

    @Override
    public void initView() {
        rl_phone=findViewById(R.id.rl_account_phone);
        rl_password=findViewById(R.id.rl_account_password);
        tv_mobile=findViewById(R.id.tv_account_mobile);
    }

    @Override
    public void initEvent() {
        rl_phone.setOnClickListener(this);
        rl_password.setOnClickListener(this);
    }

    @Override
    public void initData() {
        String ids = SpUtils.getString(this, SpUtils.USERIDS);
        new GetUserByIdsModel().getUserByIds(ids, new BaseListener() {
            @Override
            public void onResponse(Object o) {
                UserBean userBean = ((BaseObjectBean<UserBean>) o).getData();
                if (userBean != null) {
                    tv_mobile.setText(userBean.getMobile());
                }
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }
    @Override
    protected void initSetting() {
        topBar.setTitle("账号与安全");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.rl_account_phone:
                startActivity(ChangePhoneActivity.class);
                finish();
                break;
            case R.id.rl_account_password:
                startActivity(ChangePasswordActivity.class);
                finish();
                break;
        }
    }
}
